package com.qqtech.qquan.mall.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.qqtech.core.common.util.BeanUtil;
import com.qqtech.core.common.util.StringUtil;
import com.qqtech.core.frame.dao.BaseDaoImpl;
import com.qqtech.core.frame.dao.SqlId;
import com.qqtech.qquan.mall.model.MallCategory;
import com.qqtech.qquan.mall.model.MallCategoryVo;

@Repository
public class MallCategoryDaoImpl extends BaseDaoImpl<MallCategory> implements MallCategoryDao {
	public static final Logger log = LoggerFactory.getLogger(MallCategoryDaoImpl.class);

	@Override
	public Integer getMaxOidx(MallCategory mallCategory) {
		return (Integer) sqlSessionTemplate.selectOne(getSqlName("getMaxOidx"),mallCategory);
	}

	@Override
	public List<MallCategoryVo> findAllParent(String categoryId) {
		if (categoryId != null) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("categoryId", categoryId);
			return sqlSessionTemplate.selectList(getSqlName("selectAllParent"), map);
		}
		return null;
	}

	@Override
	public MallCategoryVo getByCategoryId(String categoryId) {
		return sqlSessionTemplate.selectOne(getSqlName("selectByCategoryId"), categoryId);
	}

	@Override
	public int updateByCategoryId(MallCategory entity) {
		if (StringUtil.isBlank(entity.getCategoryId())) {
			return 0;
		}
		return sqlSessionTemplate.update(getSqlName("updateByCategoryId"), entity);
	}

	@Override
	public int deleteByCategoryId(String categoryId) {
		// TODO Auto-generated method stub
		return 0;
	}
	
}
